// var o;
// exports.ElementConfig = void 0;
// var AL_GAME_HUA_Common = require("./AL_GAME_HUA_Common");
// var AL_GAME_HUA_Define = require("./AL_GAME_HUA_Define");
// var s = (function (e) {
//     function t() {
//         var t = e.call(this) || this;
//         t.elementConf = {};
//         return t;
//     }
//     __extends(t, e);
//     t.getInstance = function () {
//         return this.instance || (this.instance = new t());
//     };
//     t.prototype.destroy = function () {
//         t.instance = null;
//     };
//     t.prototype.jiazai_peizhi = function () {
//         var e = this;
//         return this.yibu_jiazai_txt_peizhi("ElementColor").then(function (t) {
//             if (t) {
//                 e.icons = [];
//                 for (var n = 0; n < t.length; n++) {
//                     e.elementConf[t[n].id] = t[n];
//                     e.icons.push(t[n].id);
//                 }
//                 e.icons.sort(function (t, n) {
//                     return e.elementConf[t].type - e.elementConf[n].type;
//                 });
//             }
//         });
//     };
//     t.prototype.huoqu_tubiao_genju_dengji = function () {
//         AL_GAME_HUA_Common.Common.huoqu_dangqian_guanqia_moshi_dengji();
//         return this.icons.slice();
//     };
//     t.prototype.huoqu_tubiao_yanse = function (e) {
//         return this.elementConf[e].hex;
//     };
//     t.prototype.huoqu_tubiao_qita = function (e) {
//         return this.elementConf[e].type;
//     };
//     t.prototype.jiazai_tubiao_icon = function (e) {
//         var t = "{" + AL_GAME_HUA_Define.Define.GAME_NAME + "}/texture/flowers/" + e;
//         return AL_GAME_HUA_Common.Common.loadRes({
//             url: t,
//             type: cc.SpriteFrame
//         }).then(function (e) {
//             return e;
//         });
//     };
//     t.instance = null;
//     return t;
// })(require("./AL_GAME_HUA_ConfigHandler").ConfigHandler);
// exports.ElementConfig = s;


const ConfigHandler = require("./AL_GAME_HUA_ConfigHandler").ConfigHandler;
const AL_GAME_HUA_Common = require("./AL_GAME_HUA_Common");
const AL_GAME_HUA_Define = require("./AL_GAME_HUA_Define");

class ElementConfig extends ConfigHandler {
    constructor() {
        super();
        this.elementConf = {};
        this.icons = [];
    }

    static getInstance() {
        if (!ElementConfig.instance) {
            ElementConfig.instance = new ElementConfig();
        }
        return ElementConfig.instance;
    }

    destroy() {
        ElementConfig.instance = null;
    }

    jiazai_peizhi() {
        return this.yibu_jiazai_txt_peizhi("ElementColor").then((loadedData) => {
            if (loadedData) {
                this.icons = [];
                loadedData.forEach((dataItem) => {
                    this.elementConf[dataItem.id] = dataItem;
                    this.icons.push(dataItem.id);
                });
                this.icons.sort((iconA, iconB) => {
                    return this.elementConf[iconA].type - this.elementConf[iconB].type;
                });
            }
        });
    }

    huoqu_tubiao_genju_dengji() {
        AL_GAME_HUA_Common.Common.huoqu_dangqian_guanqia_moshi_dengji();
        return [...this.icons];
    }

    huoqu_tubiao_yanse(iconID) {
        return this.elementConf[iconID]?.hex;
    }

    huoqu_tubiao_qita(iconID) {
        return this.elementConf[iconID]?.type;
    }

    jiazai_tubiao_icon(iconID) {
        const url = `{${AL_GAME_HUA_Define.Define.GAME_NAME}}/texture/flowers/${iconID}`;
        return AL_GAME_HUA_Common.Common.loadRes({
            url: url,
            type: cc.SpriteFrame
        }).then((loadedResource) => {
            return loadedResource;
        });
    }
}

ElementConfig.instance = null;

exports.ElementConfig = ElementConfig;